from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token

from meiduo_admin.views import orders
from .views import statistical, users
from rest_framework.routers import DefaultRouter
from .views import specs, images, skus, permissions


urlpatterns = [
    # Django REST framework JWT提供了登录签发JWT的视图，可以直接使用,但是默认的返回值仅有token
    url(r'^authorizations/$', obtain_jwt_token),

    # -------------  数据统计  --------------
    # 用户总量
    url(r'^statistical/total_count/$', statistical.UserCountView.as_view()),
    # 日增用户
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),
    # 日活用户
    url(r'^statistical/day_active/$', statistical.UserDayActiveCountView.as_view()),
    # 当日的下单用户统计
    url(r'^statistical/day_orders/$', statistical.OrderUserView.as_view()),
    # 月增用户统计
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    # 日分类商品访问量统计
    url(r'^statistical/goods_day_views/$', statistical.GoodsVisitCountView.as_view()),
    # -------------  用户管理  --------------
    url(r'^users/$', users.UserView.as_view()),
    # -------------  规格表  --------------
    url(r'^goods/simple/$', specs.SpcesView.as_view({'get': 'simple'})),
    # -------------  图片路由  --------------
    url(r'^skus/simple/$', images.ImagesView.as_view({'get': 'simple'})),
    # -------------  sku路由  --------------
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUView.as_view({'get': 'specs'})),
    # -------------  权限路由  --------------
    url(r'^permission/content_types/$', permissions.PermissionsView.as_view({'get': 'content_type'})),

]

# -------商品规格增删改查，视图集 自动生成路由------
router = DefaultRouter()
router.register('goods/specs', specs.SpcesView, base_name='specs')
# print(router.urls)
urlpatterns += router.urls

# ------图片路由表------
router = DefaultRouter()
# router.register('skus/images/', images.ImagesView.as_view({'get': ''}))
router.register('skus/images', images.ImagesView, base_name='images')
# print(router.urls)
urlpatterns += router.urls

# ------SKU路由表------
router = DefaultRouter()
# router.register('skus/images/', images.ImagesView.as_view({'get': ''}))
router.register('skus', skus.SKUView, base_name='skus')
# print(router.urls)
urlpatterns += router.urls

# ------订单路由表------
router = DefaultRouter()
router.register('orders', orders.OrdersView, base_name='orders')
# print(router.urls)
urlpatterns += router.urls

# ------权限路由表------
router = DefaultRouter()
router.register('permission/perms', permissions.PermissionsView, base_name='perms')
print(router.urls)
urlpatterns += router.urls